<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Login</title>
    </head>

    <body>
       success
    </body>
</html>


<head>
<title>File Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>


<SCRIPT language="JavaScript">

var counter =1;

function validate() {
var atch;
for(var cnt=1; cnt < counter;cnt++){
var docType =  document.getElementById("docType"+cnt).value;
if(docType!=null && docType!=''){
atch =  document.getElementById("Attachment"+cnt).value;
}

 
if(docType =='Select' && atch ==''  && cnt <= 1){
alert('Please select a Document Type ');
return false;
}

 
if(docType =='Select' &&  atch !=''){
alert('Please select a Document Type ');
return false;
}

if((atch==null ||atch=='') && docType !='Select'){
alert('Please select the Document to be uploaded');
return false;
} 
if( atch.split('.').pop() != 'pdf' && atch.split('.').pop() != 'doc'  && docType !='Select'){
alert('Only PDF or DOC files can be uploaded'); 
return false;
}

var effDate =  document.getElementById("txtEffDate"+cnt).value;

if((effDate==null ||effDate=='') && docType !='Select'){
alert('Please select an Effective Date');
return false;
} 
else{
                var validDate = /^((0?[1-9]|1[012])[/](0?[1-9]|[12][0-9]|3[01])[/])(19|20)?[0-9]{2}$/;
                
                if( !validDate.test(effDate)){
                                 alert ('Please enter an Effective Date in mm/dd/yyyy format');
                               return false;
                }

 if(!checkDate(effDate) && docType !='Select'){
   alert ('Invalid Date! Please enter a valid date.');
     return false;
 }
 

if(docType =='Select' && effDate!='' ){
alert('Please select a Document Type ');
return false;
}
 
}

document.getElementById("counter").value = counter;
  
}

fnUploadNew();
return true;
}

if (navigator.appName == 'Netscape') {
    window.captureEvents(Event.KEYPRESS);
}

function addFileUpload(){

var i = 0;
    if(counter > 15 ){
    alert('Maximum of 15 documents can only be uploaded.');
    return false;
    }
     
     while (i < 3){
      
    var div = document.createElement('DIV');
    div.innerHTML =' <TABLE border="0" cellspacing="1" height="20" align="center" style="width:75%;">'+
     
           '<TR id="fmlatableHeader" align="center">'+
        '<td width="10%"><FONT color="#FFFFFF">Doc Type</FONT></td>'+
        '<td width="10%" id=""><select id="docType'+counter+'" name="docType'+counter+'">'+
        '<option value="Select">Select</option>'+
        '<option value="NOI">Notice of Intent</option>'+
        '<option value="MRC">Medical Release</option>'+
        '<option value="CRT">Certification</option>'+
        '<option value="CRS">Correspondence</option>'+
        '<option value="APP">Approval</option>'+
        '<option value="DNL">Denial</option>'+
        '<option value="O18">Over 18 Form</option>'+
        '</select></td>'+

        '<td width="20%" id="fmlatableBeige"><input type="file" name="Attachment'+counter+'"    id="Attachment'+counter+'"  size="20" /></td>'+
        '<td width="10%"><FONT color="#FFFFFF">Effective Date</FONT></td>'+
        '<TD width="10%" height="22" id="fmlatableBeige">'+
        '<DIV align="left"><INPUT type="text" id="txtEffDate'+counter+'" name="txtEffDate'+counter+'" size="8" maxlength="10" value="" onkeydown=" return fnCatchEnterKey(event)">'+
        '<A    href="javascript:show_calendar(\'frmUpload.txtEffDate'+counter+'\');">'+
        '<IMG src="<%=FmlaPropertyConstants.FMLA_IMAGE_ROOT%>calender.gif"    width="21"></A></DIV>'+
        '</TD></TR></TABLE>';
        document.forms[0].appendChild(div);
           document.getElementById("FileUploadContainer").appendChild(div);
           document.getElementById("counter").value = counter;
   counter++;
     i++;
  }//end while

}
 
 </SCRIPT>
<BODY onload="addFileUpload()">
<!--  enctype="multipart/form-data" -->
<form name="frmUpload" method="post" enctype="multipart/form-data" action="" >





<!--  <h1>FMLA - Filenet Upload</h1> -->

<TABLE border="0" cellspacing="1" height="40" align="center" style="width:75%;">

    <TBODY >
        <TR id="">
            <TD id="">
            <div align="Left"><FONT color="#FFFFFF" size="2">Upload Documents</FONT></div>
            </TD>
        </TR>
    </TBODY>

</TABLE>
<div id="FileUploadContainer" ></div>


<br>
<br>
<TABLE align="center">
        <tr>
        <td><input type="button" name="Upload" value="Upload"
            onclick="return validate();"></td>
            <td><input id="Button1" type="button" value="Add More" onclick="addFileUpload()" /></td>
        <td><input type="button" name="Cancel" value="Cancel" onclick="window.history.back();"></td>
    </tr>
</TABLE>
<INPUT type="hidden" name="counter" id="counter" value=""> 
<INPUT type="hidden" name="htxtModule" value="UPLOAD"> <INPUT
    type="hidden" name="htxtEmpId" value="<%=strEmpId%>"> <INPUT
    type="hidden" name="htxtAction" value="UPLOAD_DOCUMENT"> <INPUT
    type="hidden" name="htxtLetterId"> <INPUT type="hidden"
    name="htxtAuthNo" value="<%=strAuthNo%>"> 
      <%
   if(null!=oDBError || null!=oError){
     if(null!= oDBError){
   %>
  <INPUT type="hidden" name="htxtErrMsg" value="<%=oDBError.getMessage()%>">
  <INPUT type="hidden" name="htxtErrorCode" value="<%=oDBError.getSqlCode()%>">
  <INPUT type="hidden" name="htxtCallingMethod" value="<%=oDBError.getCallingMethod()%>">
  <INPUT type="hidden" name="htxtCallingProgram" value="<%=oDBError.getCallingProgram()%>">
  <INPUT type="hidden" name="htxtErrorType" value="FmlaDBError">
  <%
}else{
%>
  <INPUT type="hidden" name="htxtErrMsg" value="<%=oError.getMessage()%>">
  <INPUT type="hidden" name="htxtErrorCode" value="<%=oError.getMessageType()%>">
  <INPUT type="hidden" name="htxtCallingMethod" value="<%=oError.getCallingMethod()%>">
  <INPUT type="hidden" name="htxtCallingProgram" value="<%=oError.getCallingProgram()%>">
  <INPUT type="hidden" name="htxtErrorType" value="FmlaError">
  <%
}
}
%>
    
  
</form>
</body>
</html>
